package com.yugao.fintech.antelope.shop.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yugao.fintech.antelope.base.ram.ActionType;
import com.yugao.fintech.antelope.base.ram.RamResource;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutRecordPageReq;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutRecordResp;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutRecordSaveReq;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutRecordUpdateReq;
import com.yugao.fintech.antelope.shop.service.SkuStockInOutRecordService;
import com.yugao.fintech.framework.core.response.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * 出入库存记录
 * 

 */
@Api(tags = "出入库存记录")
@RestController
@RequestMapping("/skuStockInOut/record")
public class SkuStockInOutRecordController {
    @Autowired
    private SkuStockInOutRecordService skuStockInOutRecordService;

    @ApiOperation(value = "分页出入库存记录")
    @GetMapping("/page")
    @RamResource(action = "shopGoods:skuStockInOutRecord:query", name = "查询出入库记录", type = ActionType.READ)
    public Resp<IPage<SkuStockInOutRecordResp>> pageRecord(@Validated SkuStockInOutRecordPageReq req) {
        return Resp.ok(skuStockInOutRecordService.pageRecord(req));
    }

    @ApiOperation(value = "通过id查找出入库存记录")
    @GetMapping("/get")
    @RamResource(action = "shopGoods:skuStockInOutRecord:query", name = "查询出入库记录", type = ActionType.READ)
    public Resp<SkuStockInOutRecordResp> getRecord(@RequestParam(value = "id") Long id) {
        return Resp.ok(skuStockInOutRecordService.getRecord(id));
    }
  
    @ApiOperation(value = "保存出入库存记录")
    @PostMapping("/save")
    @RamResource(action = "shopGoods:skuStockInOutRecord:save", name = "保存出入库记录", type = ActionType.WRITE)
    public Resp<?> saveRecord(@Validated @RequestBody SkuStockInOutRecordSaveReq req) {
        return Resp.ok(skuStockInOutRecordService.saveRecord(req));
    }
  
    @ApiOperation(value = "更新出入库存记录")
    @PostMapping("/update")
    @RamResource(action = "shopGoods:skuStockInOutRecord:update", name = "更新出入库记录", type = ActionType.WRITE)
    public Resp<?> updateRecord(@Validated @RequestBody SkuStockInOutRecordUpdateReq req) {
        return Resp.ok(skuStockInOutRecordService.updateRecord(req));
    }
  
    @ApiOperation(value = "批量删除出入库存记录")
    @DeleteMapping("/batchDelete")
    @RamResource(action = "shopGoods:skuStockInOutRecord:delete", name = "删除出入库记录", type = ActionType.WRITE)
    public Resp<?> batchDeleteRecord(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(skuStockInOutRecordService.batchDeleteRecord(ids));
    }
  
    @ApiOperation(value = "删除出入库存记录")
    @DeleteMapping("/delete")
    @RamResource(action = "shopGoods:skuStockInOutRecord:delete", name = "删除出入库记录", type = ActionType.WRITE)
    public Resp<?> deleteRecord(@RequestParam(value = "id") Long id) {
        return Resp.ok(skuStockInOutRecordService.deleteRecord(id));
    }
}
